<!DOCTYPE html>



  


<html class="theme-next gemini use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="linux,工具," />










<meta name="description" content="前言Tmux 是一个终端复用器（terminal multiplexer），这里记录一下tmux的使用。 转载自 Tmux 使用教程 。">
<meta property="og:type" content="article">
<meta property="og:title" content="tmux使用">
<meta property="og:url" content="http://liuyun000.gitee.io/2020/04/08/others/tmux%E4%BD%BF%E7%94%A8/index.html">
<meta property="og:site_name" content="liuyun的博客">
<meta property="og:description" content="前言Tmux 是一个终端复用器（terminal multiplexer），这里记录一下tmux的使用。 转载自 Tmux 使用教程 。">
<meta property="og:image" content="http://liuyun000.gitee.io/images/tmux.jpg">
<meta property="og:image" content="http://liuyun000.gitee.io/images/tmux_exit.jpg">
<meta property="og:image" content="http://liuyun000.gitee.io/images/tmux_spilt_window.jpg">
<meta property="article:published_time" content="2020-04-07T16:00:00.000Z">
<meta property="article:modified_time" content="2020-04-08T04:36:28.597Z">
<meta property="article:author" content="liuyun">
<meta property="article:tag" content="linux">
<meta property="article:tag" content="工具">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="http://liuyun000.gitee.io/images/tmux.jpg">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Gemini',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://liuyun000.gitee.io/2020/04/08/others/tmux使用/"/>





  <title>tmux使用 | liuyun的博客</title>
  








<meta name="generator" content="Hexo 4.2.0"></head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">liuyun的博客</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/%20" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://liuyun000.gitee.io/2020/04/08/others/tmux%E4%BD%BF%E7%94%A8/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="liuyun">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="liuyun的博客">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">tmux使用</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2020-04-08T00:00:00+08:00">
                2020-04-08
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%B7%A5%E5%85%B7/" itemprop="url" rel="index">
                    <span itemprop="name">工具</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h3 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h3><p>Tmux 是一个终端复用器（terminal multiplexer），这里记录一下tmux的使用。</p>
<p>转载自<a href="http://www.ruanyifeng.com/blog/2019/10/tmux.html" target="_blank" rel="noopener"> Tmux 使用教程 </a>。</p>
<a id="more"></a>

<br />



<h3 id="1-关于tmux"><a href="#1-关于tmux" class="headerlink" title="1. 关于tmux"></a>1. 关于tmux</h3><h4 id="1-1-会话与进程"><a href="#1-1-会话与进程" class="headerlink" title="1.1 会话与进程"></a>1.1 会话与进程</h4><p>命令行的典型使用方式是，打开一个终端窗口（terminal window，以下简称”窗口”），在里面输入命令。<strong>用户与计算机的这种临时的交互，称为一次”会话”（session）</strong> 。</p>
<p>会话的一个重要特点是，窗口与其中启动的进程是连在一起的。打开窗口，会话开始；<strong>关闭窗口，会话结束，会话内部的进程也会随之终止，不管有没有运行完。</strong></p>
<p>一个典型的例子就是，SSH 登录远程计算机，打开一个远程窗口执行命令。这时，网络突然断线，再次登录的时候，是找不回上一次执行的命令的。因为上一次 SSH 会话已经终止了，里面的进程也随之消失了。</p>
<p>为了解决这个问题，会话与窗口可以”解绑”：窗口关闭时，会话并不终止，而是继续运行，等到以后需要的时候，再让会话”绑定”其他窗口。</p>
<h4 id="1-2-tmux的作用"><a href="#1-2-tmux的作用" class="headerlink" title="1.2 tmux的作用"></a>1.2 tmux的作用</h4><ul>
<li>它允许在单个窗口中，同时访问多个会话。这对于同时运行多个命令行程序很有用。</li>
<li>它可以让新窗口”接入”已经存在的会话。</li>
<li>它允许每个会话有多个连接窗口，因此可以多人实时共享会话。</li>
<li>它还支持窗口任意的垂直和水平拆分。</li>
</ul>
<br />

<h3 id="2-使用"><a href="#2-使用" class="headerlink" title="2. 使用"></a>2. 使用</h3><h4 id="2-1-安装"><a href="#2-1-安装" class="headerlink" title="2.1 安装"></a>2.1 安装</h4><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash"> Ubuntu 或 Debian</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> sudo apt-get install tmux</span></span><br><span class="line"></span><br><span class="line"><span class="meta">#</span><span class="bash"> CentOS 或 Fedora</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> sudo yum install tmux</span></span><br><span class="line"></span><br><span class="line"><span class="meta">#</span><span class="bash"> Arch 或 Manjaro</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> sudo pacman -S tmux</span></span><br></pre></td></tr></table></figure>

<h4 id="2-2-启动、退出"><a href="#2-2-启动、退出" class="headerlink" title="2.2 启动、退出"></a>2.2 启动、退出</h4><p>直接输入tmux就可以进入tmux窗口。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">$</span><span class="bash"> tmux</span></span><br></pre></td></tr></table></figure>

<p><img src="/images/tmux.jpg" alt="tmux"></p>
<p>按<code>Ctrl+d</code>或者输入<code>exit</code>，就可以退出tmux。</p>
<p><img src="/images/tmux_exit.jpg" alt="tmux退出"></p>
<br />

<h3 id="3-会话管理"><a href="#3-会话管理" class="headerlink" title="3. 会话管理"></a>3. 会话管理</h3><h4 id="3-1-新建会话"><a href="#3-1-新建会话" class="headerlink" title="3.1 新建会话"></a>3.1 新建会话</h4><p>第一个启动的 Tmux 窗口，编号是0，第二个窗口的编号是1，以此类推。这些窗口对应的会话，就是 0 号会话、1 号会话。</p>
<p>使用编号区分会话，不太直观，更好的方法是为会话起名。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash"> 新建一个指定名称的会话。</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> tmux new -s &lt;session-name&gt;</span></span><br></pre></td></tr></table></figure>

<h4 id="3-2-分离会话"><a href="#3-2-分离会话" class="headerlink" title="3.2 分离会话"></a>3.2 分离会话</h4><p>在 Tmux 窗口中，按下<code>Ctrl+b d</code>（先同时按下Ctrl和b，都松开后再按d，类似表示下同）或者输入<code>tmux detach</code>命令，就会将当前会话与窗口分离，但是会话和里面的进程仍然在后台运行。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">$</span><span class="bash"> tmux detach</span></span><br></pre></td></tr></table></figure>

<p><code>tmux ls</code>命令可以查看当前所有的 Tmux 会话。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">$</span><span class="bash"> tmux ls</span></span><br></pre></td></tr></table></figure>

<h4 id="3-3-接入会话"><a href="#3-3-接入会话" class="headerlink" title="3.3 接入会话"></a>3.3 接入会话</h4><p><code>tmux a</code>（<code>a</code>是<code>attch</code>和<code>attach-session</code>的简写，可互换）命令用于重新接入某个已存在的会话。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash"> 使用会话编号</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> tmux attach -t 0</span></span><br><span class="line"></span><br><span class="line"><span class="meta">#</span><span class="bash"> 使用会话名称</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> tmux attach -t &lt;session-name&gt;</span></span><br></pre></td></tr></table></figure>

<h4 id="3-4-杀死会话"><a href="#3-4-杀死会话" class="headerlink" title="3.4 杀死会话"></a>3.4 杀死会话</h4><p><code>tmux kill-session</code>命令用于杀死某个会话。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash"> 使用会话编号</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> tmux <span class="built_in">kill</span>-session -t 0</span></span><br><span class="line"></span><br><span class="line"><span class="meta">#</span><span class="bash"> 使用会话名称</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> tmux <span class="built_in">kill</span>-session -t &lt;session-name&gt;</span></span><br></pre></td></tr></table></figure>

<h4 id="3-5-切换会话"><a href="#3-5-切换会话" class="headerlink" title="3.5 切换会话"></a>3.5 切换会话</h4><p><code>tmux switch</code>命令用于切换会话。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash"> 使用会话编号</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> tmux switch -t 0</span></span><br><span class="line"></span><br><span class="line"><span class="meta">#</span><span class="bash"> 使用会话名称</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> tmux switch -t &lt;session-name&gt;</span></span><br></pre></td></tr></table></figure>

<h4 id="3-6-重命名会话"><a href="#3-6-重命名会话" class="headerlink" title="3.6 重命名会话"></a>3.6 重命名会话</h4><p><code>tmux rename-session</code>命令用于重命名会话。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">$</span><span class="bash"> tmux rename-session -t 0 &lt;new-name&gt;</span></span><br></pre></td></tr></table></figure>

<h4 id="3-7-会话快捷键"><a href="#3-7-会话快捷键" class="headerlink" title="3.7 会话快捷键"></a>3.7 会话快捷键</h4><p>下面是一些会话相关的快捷键。</p>
<ul>
<li><code>Ctrl+b d</code>：分离当前会话。</li>
<li><code>Ctrl+b s</code>：列出所有会话。</li>
<li><code>Ctrl+b $</code>：重命名当前会话。</li>
</ul>
<br />

<h4 id="4-最简操作流程"><a href="#4-最简操作流程" class="headerlink" title="4. 最简操作流程"></a>4. 最简操作流程</h4><p>综上所述，以下是 Tmux 的最简操作流程。</p>
<ol>
<li>新建会话<code>tmux new -s my_session</code>。</li>
<li>在 Tmux 窗口运行所需的程序。</li>
<li>按下快捷键<code>Ctrl+b d</code>将会话分离。</li>
<li>下次使用时，重新连接到会话<code>tmux a -t my_session</code>。</li>
</ol>
<br />

<h3 id="5-窗格操作"><a href="#5-窗格操作" class="headerlink" title="5. 窗格操作"></a>5. 窗格操作</h3><p>Tmux 可以将窗口分成多个窗格（pane），每个窗格运行不同的命令。以下命令都是在 Tmux 窗口中执行。</p>
<h4 id="5-1-划分窗格"><a href="#5-1-划分窗格" class="headerlink" title="5.1 划分窗格"></a>5.1 划分窗格</h4><p><code>tmux split-window</code>命令用来划分窗格。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash"> 划分上下两个窗格</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> tmux split-window</span></span><br><span class="line"></span><br><span class="line"><span class="meta">#</span><span class="bash"> 划分左右两个窗格</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> tmux split-window -h</span></span><br></pre></td></tr></table></figure>

<p><img src="/images/tmux_spilt_window.jpg" alt="tmux划分窗格"></p>
<h4 id="5-2-移动光标"><a href="#5-2-移动光标" class="headerlink" title="5.2 移动光标"></a>5.2 移动光标</h4><p><code>tmux select-pane</code>命令用来移动光标位置。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash"> 光标切换到上方窗格</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> tmux select-pane -U</span></span><br><span class="line"></span><br><span class="line"><span class="meta">#</span><span class="bash"> 光标切换到下方窗格</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> tmux select-pane -D</span></span><br><span class="line"></span><br><span class="line"><span class="meta">#</span><span class="bash"> 光标切换到左边窗格</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> tmux select-pane -L</span></span><br><span class="line"></span><br><span class="line"><span class="meta">#</span><span class="bash"> 光标切换到右边窗格</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> tmux select-pane -R</span></span><br></pre></td></tr></table></figure>

<h4 id="5-3-交换窗格位置"><a href="#5-3-交换窗格位置" class="headerlink" title="5.3 交换窗格位置"></a>5.3 交换窗格位置</h4><p><code>tmux swap-pane</code>命令用来交换窗格位置。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash"> 当前窗格上移</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> tmux swap-pane -U</span></span><br><span class="line"></span><br><span class="line"><span class="meta">#</span><span class="bash"> 当前窗格下移</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> tmux swap-pane -D</span></span><br></pre></td></tr></table></figure>

<h4 id="5-4-窗格快捷键"><a href="#5-4-窗格快捷键" class="headerlink" title="5.4 窗格快捷键"></a>5.4 窗格快捷键</h4><p>下面是一些窗格操作的快捷键。</p>
<ul>
<li><code>Ctrl+b %</code>：划分左右两个窗格。</li>
<li><code>Ctrl+b &quot;</code>：划分上下两个窗格。</li>
<li><code>Ctrl+b &lt;方向键&gt;</code>：光标切换到其他窗格。&lt;方向键&gt;是指向要切换到的窗格的方向键，比如切换到下方窗格，就按方向键↓。</li>
<li><code>Ctrl+b ;</code>：光标切换到上一个窗格。</li>
<li><code>Ctrl+b o</code>：光标切换到下一个窗格。</li>
<li><code>Ctrl+b {</code>：当前窗格左移。</li>
<li><code>Ctrl+b }</code>：当前窗格右移。</li>
<li><code>Ctrl+b Ctrl+o</code>：当前窗格上移。</li>
<li><code>Ctrl+b Alt+o</code>：当前窗格下移。</li>
<li><code>Ctrl+b x</code>：关闭当前窗格。</li>
<li><code>Ctrl+b !</code>：将当前窗格拆分为一个独立窗口。</li>
<li><code>Ctrl+b z</code>：当前窗格全屏显示，再使用一次会变回原来大小。</li>
<li><code>Ctrl+b Ctrl+&lt;方向键&gt;</code>：按箭头方向调整窗格大小。</li>
<li><code>Ctrl+b q</code>：显示窗格编号。</li>
</ul>
<br />

<h3 id="6-窗口管理"><a href="#6-窗口管理" class="headerlink" title="6. 窗口管理"></a>6. 窗口管理</h3><p>除了将一个窗口划分成多个窗格，Tmux 也允许新建多个窗口。</p>
<h4 id="6-1-新建窗口"><a href="#6-1-新建窗口" class="headerlink" title="6.1 新建窗口"></a>6.1 新建窗口</h4><p><code>tmux new-window</code>命令用来创建新窗口。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">$</span><span class="bash"> tmux new-window</span></span><br><span class="line"></span><br><span class="line"><span class="meta">#</span><span class="bash"> 新建一个指定名称的窗口</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> tmux new-window -n &lt;window-name&gt;</span></span><br></pre></td></tr></table></figure>

<h4 id="6-2-切换窗口"><a href="#6-2-切换窗口" class="headerlink" title="6.2 切换窗口"></a>6.2 切换窗口</h4><p><code>tmux select-window</code>命令用来切换窗口。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash"> 切换到指定编号的窗口</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> tmux select-window -t &lt;window-number&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="meta">#</span><span class="bash"> 切换到指定名称的窗口</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> tmux select-window -t &lt;window-name&gt;</span></span><br></pre></td></tr></table></figure>

<h4 id="6-3-重命名窗口"><a href="#6-3-重命名窗口" class="headerlink" title="6.3 重命名窗口"></a>6.3 重命名窗口</h4><p><code>tmux rename-window</code>命令用于为当前窗口起名（或重命名）。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">$</span><span class="bash"> tmux rename-window &lt;new-name&gt;</span></span><br></pre></td></tr></table></figure>

<ul>
<li><code>Ctrl+b c</code>：创建一个新窗口，状态栏会显示多个窗口的信息。</li>
<li><code>Ctrl+b p</code>：切换到上一个窗口（按照状态栏上的顺序）。</li>
<li><code>Ctrl+b n</code>：切换到下一个窗口。</li>
<li><code>Ctrl+b &lt;数字键&gt;</code>：切换到指定编号的窗口，其中的&lt;数字键&gt;是状态栏上的窗口编号。</li>
<li><code>Ctrl+b w</code>：从列表中选择窗口。</li>
<li><code>Ctrl+b ,</code>：窗口重命名。</li>
</ul>
<br />

<h3 id="7-其他命令"><a href="#7-其他命令" class="headerlink" title="7. 其他命令"></a>7. 其他命令</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash"> 列出所有快捷键，及其对应的 Tmux 命令</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> tmux list-keys</span></span><br><span class="line"></span><br><span class="line"><span class="meta">#</span><span class="bash"> 列出所有 Tmux 命令及其参数</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> tmux list-commands</span></span><br><span class="line"></span><br><span class="line"><span class="meta">#</span><span class="bash"> 列出当前所有 Tmux 会话的信息</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> tmux info</span></span><br><span class="line"></span><br><span class="line"><span class="meta">#</span><span class="bash"> 重新加载当前的 Tmux 配置</span></span><br><span class="line"><span class="meta">$</span><span class="bash"> tmux <span class="built_in">source</span>-file ~/.tmux.conf</span></span><br></pre></td></tr></table></figure>


      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/linux/" rel="tag"># linux</a>
          
            <a href="/tags/%E5%B7%A5%E5%85%B7/" rel="tag"># 工具</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2020/03/13/%E9%80%86%E5%90%91/%E7%A1%AC%E7%BC%96%E7%A0%81/" rel="next" title="硬编码">
                <i class="fa fa-chevron-left"></i> 硬编码
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2020/04/19/%E9%80%86%E5%90%91/windbg+vbox+win7%E8%99%9A%E6%8B%9F%E6%9C%BA/" rel="prev" title="Windows内核调试 winbdg+vbox+win7虚拟机">
                Windows内核调试 winbdg+vbox+win7虚拟机 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <p class="site-author-name" itemprop="name">liuyun</p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/%20%7C%7C%20archive">
              
                  <span class="site-state-item-count">16</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/categories/index.html">
                  <span class="site-state-item-count">9</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/tags/index.html">
                  <span class="site-state-item-count">21</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          

          

          
          

          
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#前言"><span class="nav-number">1.</span> <span class="nav-text">前言</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-关于tmux"><span class="nav-number">2.</span> <span class="nav-text">1. 关于tmux</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#1-1-会话与进程"><span class="nav-number">2.1.</span> <span class="nav-text">1.1 会话与进程</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#1-2-tmux的作用"><span class="nav-number">2.2.</span> <span class="nav-text">1.2 tmux的作用</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-使用"><span class="nav-number">3.</span> <span class="nav-text">2. 使用</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#2-1-安装"><span class="nav-number">3.1.</span> <span class="nav-text">2.1 安装</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#2-2-启动、退出"><span class="nav-number">3.2.</span> <span class="nav-text">2.2 启动、退出</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-会话管理"><span class="nav-number">4.</span> <span class="nav-text">3. 会话管理</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#3-1-新建会话"><span class="nav-number">4.1.</span> <span class="nav-text">3.1 新建会话</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#3-2-分离会话"><span class="nav-number">4.2.</span> <span class="nav-text">3.2 分离会话</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#3-3-接入会话"><span class="nav-number">4.3.</span> <span class="nav-text">3.3 接入会话</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#3-4-杀死会话"><span class="nav-number">4.4.</span> <span class="nav-text">3.4 杀死会话</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#3-5-切换会话"><span class="nav-number">4.5.</span> <span class="nav-text">3.5 切换会话</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#3-6-重命名会话"><span class="nav-number">4.6.</span> <span class="nav-text">3.6 重命名会话</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#3-7-会话快捷键"><span class="nav-number">4.7.</span> <span class="nav-text">3.7 会话快捷键</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#4-最简操作流程"><span class="nav-number">4.8.</span> <span class="nav-text">4. 最简操作流程</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#5-窗格操作"><span class="nav-number">5.</span> <span class="nav-text">5. 窗格操作</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#5-1-划分窗格"><span class="nav-number">5.1.</span> <span class="nav-text">5.1 划分窗格</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#5-2-移动光标"><span class="nav-number">5.2.</span> <span class="nav-text">5.2 移动光标</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#5-3-交换窗格位置"><span class="nav-number">5.3.</span> <span class="nav-text">5.3 交换窗格位置</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#5-4-窗格快捷键"><span class="nav-number">5.4.</span> <span class="nav-text">5.4 窗格快捷键</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#6-窗口管理"><span class="nav-number">6.</span> <span class="nav-text">6. 窗口管理</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#6-1-新建窗口"><span class="nav-number">6.1.</span> <span class="nav-text">6.1 新建窗口</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#6-2-切换窗口"><span class="nav-number">6.2.</span> <span class="nav-text">6.2 切换窗口</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#6-3-重命名窗口"><span class="nav-number">6.3.</span> <span class="nav-text">6.3 重命名窗口</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#7-其他命令"><span class="nav-number">7.</span> <span class="nav-text">7. 其他命令</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2020</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">liuyun</span>

  
</div>


  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Gemini</a> v5.1.4</div>




        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.4"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  

  

  
  

  

  

  

<script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginModelPath":"assets/","model":{"jsonPath":"/live2dw/assets/miku.model.json"},"display":{"position":"right","width":150,"height":300},"mobile":{"show":false},"log":false,"pluginJsPath":"lib/","pluginRootPath":"live2dw/","tagMode":false});</script></body>
</html>
